'use strict';

angular.module('app')
	.controller('statsDataForCompanyLaunchController', [ '$rootScope', '$scope', '$http', '$state',
	                                function($rootScope, $scope, $http, $state) {
		$scope.title = '公司投放统计';
        $scope.searchParams = { };
        $scope.loading = false;

		$scope.search = function () {
	        $scope.loading = true;
			$.ajax({
				url : $scope.app.project_name+ '/statsData/read/companyLaunch',
				data: $scope.searchParams
			}).then(function(result) {
		        $scope.loading = false;
				if (result.httpCode == 200) {
					$scope.pageInfo = result.data;
				} else {
					$scope.msg = result.msg;
				}
				$scope.$apply();
			});
		};
		$scope.searchRe = function () {
			$scope.loading = true;
			$scope.searchParams.pageNum = 1;
            $scope.searchParams.StartTime = $("#StartTime").val();
            $scope.searchParams.EndTime = $("#EndTime").val();
			$.ajax({
				url : $scope.app.project_name+ '/statsData/read/companyLaunch',
				data: $scope.searchParams
			}).then(function(result) {
				$scope.loading = false;
				if (result.httpCode == 200) {
					$scope.pageInfo = result.data;
				} else {
					$scope.msg = result.msg;
				}
				$scope.$apply();
			});
		};

      	//清空
		$scope.clearSearch = function() {
			$scope.searchParams= {};
            $("#StartTime").val("");
            $("#EndTime").val("");
			$scope.search();
		};

		// 翻页
		$scope.pagination = function (pageNo) {
			$scope.searchParams.pageNum=pageNo;
			$scope.search();
		};

         $scope.search();
} ]);